﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SmartMedicalCare.API.Write.Applications.Commands;
using SmartMedicalCare.API.Write.Applications.Commands.一级科室;
using SmartMedicalCare.API.Write.Applications.Commands.二级科室;
using SmartMedicalCare.API.Write.Applications.Commands.轮播图;
using SmartMedicalCare.Domain;
using SmartMedicalCare.ErronCode;

namespace SmartMedicalCare.API.Write.Controllers
{
    /// <summary>
    /// 控制器—写
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ManagementController : ControllerBase
    {
        /// <summary>
        /// 中介者1
        /// </summary>
        private readonly IMediator mediator;
        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="mediator">中介者</param>
        public ManagementController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 轮播图添加方法
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> AddCarousel(AddCarouselCommand command)
        {
            return await mediator.Send(command);
        }
        /// <summary>
        /// 一级科室添加
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> AddDepartment(AddDepartmentCommand command)
        {
            return await mediator.Send(command);
        }
        /// <summary>
        /// 二级科室添加方法
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> AddDeptSubCategory(AddDeptSubCategoryCommand command)
        {
            return await mediator.Send(command);
        }
        /// <summary>
        /// 创建医院表信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> AddHospital(AddHospitalCommand command)
        {
            return await mediator.Send(command);
        }

        /// <summary>
        /// 轮播图删除接口
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<APIResult<int>> DeleteCarousel(DeleteCarouselCommand command)
        {
            return await mediator.Send(command);
        }
        /// <summary>
        /// 轮播图修改接口
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<APIResult<int>> UpdateCarousel(UpdateCarouselCommand command)
        {
            return await mediator.Send(command);
        }


        /// <summary>
        /// 一级科室逻辑删除接口
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpDelete]    
        public async Task<APIResult<int>> DeleteDepartment(DeleteDepartmentCommand command)
        {
            return await mediator.Send(command);
        }
        /// <summary>
        /// 一级科室修改接口
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<APIResult<int>> UpdateDepartment(UpdateDepartmentCommand command)
        {
            return await mediator.Send(command);
        }
        /// <summary>
        /// 二级科室删除接口
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<APIResult<int>> DeleteDeptSubCategory(DeleteDeptSubCategoryCommand command)
        {
            return await mediator.Send(command);
        }
        /// <summary>
        /// 二级科室修改接口
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<APIResult<int>> UpdateDeptSubCategory(UpdateDeptSubCategoryCommand command)
        {
            return await mediator.Send(command);
        }

        /// <summary>
        /// 医院科室逻辑删除接口
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<APIResult<int>> DeleteHospital(DeleteHospitalCommand command)
        {
            return await mediator.Send(command);
        }



    }
}
